package com.wzw.basics.encryption;

import java.nio.charset.StandardCharsets;

/**
 * @author Wangzhiwen
 */
public class EncryptionMain {

    public static void rsa() throws Exception {
        String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDKn803D6+akrV6j0MU7DciaG6juByNw8id/xpawpHXX1nnLt+AlTWQ+JPc5zCNmGvK9aC8D6DjgHzFNc2cXUiyATJxZ4L9FKDRXe0d1vYGXAzusJ5DmHq5b9t092LDkc6Sv9GCWV5O6IiEXWQ5epPjNp+CNzONiYvyVrOd+zMALQIDAQAB";
        String privateKey = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMqfzTcPr5qStXqPQxTsNyJobqO4HI3DyJ3/GlrCkddfWecu34CVNZD4k9znMI2Ya8r1oLwPoOOAfMU1zZxdSLIBMnFngv0UoNFd7R3W9gZcDO6wnkOYerlv23T3YsORzpK/0YJZXk7oiIRdZDl6k+M2n4I3M42Ji/JWs537MwAtAgMBAAECgYANVBu0roR3n4TujfP0sWEjE0mL3XWLYcCVnA1IwRnE2BHa4jtzgt0mLyPS2SZZehhFHok3NbP4oyAR/OsMiRpZ9Rf2ELGht0cPVHW7i5yZnZx9VGIpFKzVIi+VAQLCOw9mIl5RZMOGG6G7oG8AqNmXji632KLYen26WlNvzhVvxQJBAPy6mERZLozViDRNJgn8vagzpkQ3UvTu+NEEIYBYjNexquV34f3V9z3RHIrsaWVQv/Kj5At0Y8oTlL1F+N19gDMCQQDNPy/5ypdtrcu3AxPtgcq9GzOWaojoFDnR7We9IDsDadq+PC/DOFx3t0V9KB2G9zjk9DF6oCiKT2aQHh+Xm54fAkEAwWdmaT+6YOp0Llov1wrEdPj5r1CLOoe6f/HiVV7ugY4kUzDYEDHy4Cqr5iCfU3plOiFzvdRXHWi4tdPbbFzDgwJAZpWScRMlJJidHVfYeflJT8NswV12GCkjzR0PoKOfW1FpF3QVm0lsThm4DZojR/YA5c53fIbYPGj7JkUoHSqWmQJACY+y97TnHut0PomjS+FEXxmHHMV/X0Ie8Fl2K0MYpjkmjYAAUAjRxtCA7KXhcr8kBXapB5SsIXa5vG5Xxl7DmA==";
        String data = "Test Rsa";
        byte[] encrypt = RSAEncryption.encryptByPublicKey(data.getBytes(StandardCharsets.UTF_8), publicKey);
        byte[] decrypt = RSAEncryption.decryptByPrivateKey(encrypt, privateKey);
        System.out.println(new String(decrypt,StandardCharsets.UTF_8));
    }

    public static void sha1(){
        HmacSHA1Encryption.encrypt("xxxx");
    }

    public static void main(String[] args) throws Exception {
        rsa();
        sha1();
    }
}
